home *** CD-ROM | disk | FTP | other *** search
/ Family Forum 261 / SOMC Family Forum 261.iso / Xtras / Behavior Library.cst / 00024_Script_Image Cycle Cast Members < prev    next >
Text File  |  1997-11-17  |  5KB  |  125 lines

  1. -- Image Cycle Members
  2.  
  3.  
  4. -- n state cycling, bounce list
  5. -- relies on cast members being contiguous
  6. -- exports SetState and CycleState
  7. -- if receives a CycleState event, it checks it's name and increments the state
  8.  
  9. -- behavior library version 1.1
  10.  
  11. property Enabled
  12. property MemberMin, MemberMax, ImageCastLib, MemberRefMin, MemberRefMax
  13. property CycleStyle  -- cycling, bouncing
  14. -- memberMin and memberMax are actually membernumbers, as is currentstate
  15.  
  16. property goingDown   -- TRUE  if going through the list in reverse order
  17. --                      FALSE if traversing the list normally
  18.  
  19. property CurrentState
  20. property NumStates
  21.  
  22. property name
  23.  
  24. on CycleState me, name
  25.   if name = the name of me then
  26.     bumpstate_intern me
  27.   end if 
  28. end
  29.  
  30. on SetState me, statenum
  31.   if the enabled of me then
  32.     if statenum > the numstates of me then 
  33.       set statenum = the numstates of me
  34.     else if statenum < 1 then 
  35.       set statenum = 1
  36.     end if
  37.     set the member of sprite the spritenum of me =             member ( the membermin of me + statenum - 1 ) of castLib imageCastLib
  38.   end if
  39. end
  40.  
  41. on setGoingDown me, value
  42.   set the goingDown of me to value
  43. end
  44.  
  45. on SetCycleStyle me, value
  46.   set the CycleStyle of me to value
  47. end
  48.  
  49. ---
  50.  
  51.  
  52. on bumpstate_intern me
  53.   if the enabled of me then
  54.     if ( the CycleStyle of me = #Repeat ) then 
  55.       if NOT the goingDown of me then -- going Up
  56.         set curr = the currentstate of me  + 1
  57.         if curr > the numstates of me then 
  58.           set curr = 1
  59.         end if
  60.       else -- going Down
  61.         set curr = the currentstate of me  - 1
  62.         if curr < 1 then set curr = the numstates of me
  63.       end if
  64.       
  65.     else   -- Reverse cycle
  66.       if NOT the goingDown of me then -- going Up 
  67.         set curr = the currentstate of me  + 1
  68.         if curr > the numstates of me then
  69.           set curr = curr - 2
  70.           set the goingDown of me = TRUE
  71.         end if
  72.       else   -- going Down
  73.         set curr = the currentstate of me  - 1
  74.         if curr < 1 then
  75.           set curr = 2
  76.           set the goingDown of me = FALSE
  77.         end if
  78.       end if
  79.     end if
  80.     
  81.     set the currentstate of me = curr
  82.     setstate me, curr
  83.   end if  
  84. end
  85.  
  86. on BeginSprite me
  87.   set the enabled of me = TRUE
  88.   set the membermin of me = the membernum of member memberRefMin
  89.   set the membermax of me = the membernum of member memberRefMax
  90.   
  91.   set the numstates of me = (the membermax of me) - (the membermin of me) + 1
  92.   
  93.   set the currentState of me = ( the memberNum of sprite the spriteNum of me ) -                                  the MemberMin of me + 1
  94.   set the imageCastLib of me = the number of castLib                                        ( the castLibNum of sprite ( the spriteNum of me ))
  95.   setstate me, the currentstate of me
  96. end
  97.  
  98. on getPropertyDescriptionList
  99.   if the currentspritenum = 0 then 
  100.     set memdefault = 0 
  101.   else
  102.     
  103.     set memref = the member of sprite the currentspritenum
  104.     set castlibnum = the castlibnum of memref
  105.     set memdefault = member (the membernum of member memref + 1) of castlib castlibnum
  106.   end if
  107.   
  108.   set p_list = [           #Name: [ #comment:   "Item Name:",                     #format:   #symbol,                    #default:   #MultiState_1 ],      #MemberRefMin: [ #comment:   "First Image:",                     #format:   #graphic,                    #default:    memref ],      #MemberRefMax: [ #comment:   "Last Image:",                     #format:   #graphic,                    #default:    memdefault ],     #CycleStyle: [ #comment:   "Cycle Style:",                     #format:   #symbol,                      #range: [ #Repeat, #Reverse ],                    #default:   #Repeat ],      #GoingDown: [ #comment:   "Reverse Order:",                     #format:   #boolean,                    #default:    FALSE ]                  ]
  109.   return p_list  
  110.   
  111. end
  112.  
  113. on getBehaviorDescription
  114.   return "Makes the sprite cycle through a range of cast members when the CycleState message is received." & RETURN & "PARAMETERS:" & RETURN & "ò Item Name - (optional) Enter an item name to identify the current sprite so that it can receive a specific message. Do not use spaces. Use the name as an argument for the Message Sprite or Message All Sprites behaviors."  & RETURN & "ò First Image - Enter the name of the first cast member in the cycling range."  & RETURN & "ò Last Image  - Enter the name of the last cast member in the cycling range."  & RETURN & "ò Cycle Mode - Choose Repeat to repeat the same sequence.  Choose Reverse to cycle back through the sequence in reverse order." & RETURN & "ò Reverse Order - Turn this option on to proceed from the last to the first image by default."  & RETURN & "MESSAGES:" & RETURN & "ò CycleState - Switches the sprite's cast member to the next image in the sequence." & RETURN & "ò SetState state_number - Advances directly to the position in the sequence identified by state_number."
  115.   
  116. end
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.